package com.cs.manaer.controller;

import com.cs.manaer.controller.req.ListSystemNotifyReqMsg;
import com.cs.manaer.controller.req.SystemNotifyReqMsg;
import com.cs.manaer.controller.res.ListSystemNotifyResMsg;
import com.cs.manaer.service.SystemNotifyService;
import com.lin.common.rest.ResMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/web")
public class SystemNotifyController {

    @Autowired
    private SystemNotifyService systemNotifyService;


    @PostMapping("/publishnotify/{id}")
    public ResMsg<Integer> publishSystemNotify(@PathVariable Long id) throws Exception {
        ResMsg<Integer> rm = new ResMsg<>();
        return rm.withData(systemNotifyService.publishSystemNotify(id));
    }

    @PostMapping("/listnotify")
    public ResMsg<ListSystemNotifyResMsg> listSystemNotify(ListSystemNotifyReqMsg reqMsg) {
        //BaseController.verify(bindingResult);
        ResMsg<ListSystemNotifyResMsg> urs = new ResMsg<>();
        return urs.withData(systemNotifyService.listSystemNotify(reqMsg));
    }

    @PostMapping("/addnotify")
    public ResMsg<Integer> addSystemNotify(@Valid @RequestBody SystemNotifyReqMsg reqMsg) throws Exception {
        ResMsg<Integer> rm = new ResMsg<>();
        return rm.withData(systemNotifyService.addSystemNotify(reqMsg));
    }

    @PostMapping("/delnotify/{id}")
    public ResMsg<Integer> delSystemNotify(@PathVariable Long id) throws Exception {
        ResMsg<Integer> rm = new ResMsg<>();
        return rm.withData(systemNotifyService.delSystemNotify(id));
    }
}
